Show Case


Image Filters

Introduction

This was one of the first projects that I did, this is through the CS50 course. I only did the implementation of the filters which include, edge detection, grayscale, reflect, blur. There is a part of the program I will not be showing the reason being because it was given to me, that part of the code read in the image as an objects so I could then read through the rows of pixels. To see my implimentation of memory allocation and object creation in the C language take a look at Generation Generator project.

Filters

The filters are blur, edge detection, grayscale, reflect.

Reflection

I'm happy with how this one works, it is simple, and it is a nicely used function to declutter the main function.

Stadium Picture
Before Filter
Stadium Reflected Picture
After Filter

The Breakdown

This is a easy problem to solve. The only factors are what axis to flip the image across and how to preserve the pixel on one side when it has been overwritten.

Reflect Main
Main Function

x defines the center of center of the image. Then it loops through the height and half the width of the image. rgbmove finds the pixel that is opposite the current pixel on the x-axis. This will be the pixel that is moved. It then calls the swtch function

Switching Pixels
Flipping Pixels

ogrgb get the origonal pixel that is at possition (h, w) because this is then overwritten in the following line. It is overwritten by the pixel that is opposite it on the x-axis. Then the pixel that is opposite is overwritten by the OG pixel.

Summary

This one is simple and follows some basic rules. Such as the breaking out of actions to keep functions decluttered.